package me.zhengjie.modules.system.service

import jakarta.servlet.http.HttpServletResponse
import me.zhengjie.modules.security.service.dto.AuthorityDto
import me.zhengjie.modules.system.domain.*
import me.zhengjie.modules.system.service.dto.RoleDTO
import me.zhengjie.modules.system.service.dto.UserDTO
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria
import me.zhengjie.modules.system.service.dto.RoleSmallDTO
import org.springframework.data.domain.Pageable
import java.io.IOException

/**
 * @author Kuki Wu
 * @date 2018-12-03
 */
interface RoleService {
    fun findById(id: Long): RoleDTO
    fun create(resources: Role): RoleDTO?
    fun update(resources: Role)
    fun delete(id: Long)
    fun findByUsersId(id: Long?): List<RoleSmallDTO?>?
    fun findByRoles(roles: Set<Role>): Int
    fun updateMenu(resources: Role, roleDTO: RoleDTO)
    fun untiedMenu(id: Long?)
    fun queryAll(pageable: Pageable?): Any?
    fun queryAll(criteria: RoleQueryCriteria, pageable: Pageable?): Any?
    fun queryAll(criteria: RoleQueryCriteria): List<RoleDTO?>?

    @Throws(IOException::class)
    fun download(queryAll: List<RoleDTO>, response: HttpServletResponse?)

    /**
     * 获取用户权限信息
     * @param user 用户信息
     * @return 权限信息
     */
    fun mapToGrantedAuthorities(user: UserDTO?): List<AuthorityDto?>?

    /**
     * 验证是否被用户关联
     * @param ids /
     */
    fun verification(ids: Set<Long?>?)

    /**
     * 根据菜单Id查询
     * @param menuIds /
     * @return /
     */
    fun findInMenuId(menuIds: List<Long?>?): List<Role?>?
}